﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.IO.IsolatedStorage;
using TencentWeiboSDK.Model;
using Microsoft.Phone.Shell;

namespace TencentWeiboSample
{
    public partial class LoginView : PhoneApplicationPage
    {
        // 构造函数
        public LoginView()
        {
            InitializeComponent();
        }

        private void Login()
        {
            // 开始进行 OAuth 授权.
            oAuthLoginBrowser1.OAuthLogin((callback) =>
            {
                // 若已获得 AccessToken 则跳转到 TimelineView 页面
                // 注意： 若 OAuthConfigruation.IfSaveAccessToken 属性为 False，则需要在此处保存用户的 AccessToken(callback.Data) 以便下次使用.
                if (callback.Succeed)
                {
                    NavigationService.Navigate(new Uri("/TimelineView.xaml", UriKind.RelativeOrAbsolute));
                }
            });
        }

        private void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
        {
            Login();
        }
    }
}